﻿using System;
using System.Xml;
using System.Xml.Serialization;

namespace SMARTMobile
{
    [XmlRoot("Configuration")]
    public class SMConfiguration
    {
        private static object SyncRoot = new object();
        private static SMConfiguration _current;

        [XmlElement]
        public string UserAgentFormat { get; set; }

        [XmlElement]
        public string LocationCode { get; set; }

        [XmlElement]
        public string BaseUri { get; set; }

        public static SMConfiguration Current
        {
            get
            {
                if (null == _current)
                {
                    lock (SyncRoot)
                    {
                        if (null == _current)
                        {
                            using (var reader = XmlReader.Create("Configuration.xml"))
                            {
                                var s = new XmlSerializer(typeof(SMConfiguration));
                                _current = s.Deserialize(reader) as SMConfiguration;
                            }
                        }
                    }
                }
                return _current;
            }
        }
    }
}
